//newAct.js

var util = require('../../utils/util.js');  
var name
var content
var startTime
var endTime
var UserID 
var time = util.formatTime(new Date())
//获取应用实例
var app = getApp()

Page({
  data: {
   startTime:time
  },
  onLoad: function (options) {
    name=null;
    content=null;
    startTime=null;
    endTime=null;
    UserID = app.globalData.UserID;
    console.log(UserID);
  },
    bindKeyInput1: function(e) {
          name = e.detail.value;
          
    },

  bindKeyInput1: function(e) {
    name = e.detail.value;
    // console.log(name);
    this.setData({
      activityName: e.detail.value
    })
  },

  bindKeyInput2: function (e) {
    content = e.detail.value
    this.setData({
      activityContent: e.detail.value
    })
  },
  
  //事件处理函数
  bindDateChange1: function (e) {
    startTime = e.detail.value
    
    this.setData({
      dates1: e.detail.value
    })
  },
  bindDateChange2: function (e) {
    endTime = e.detail.value
    // console.log(e.detail.value)
    this.setData({
      dates2: e.detail.value
    })
  },


   
  new:function(e){
   if(name==null||content==null||startTime==null||endTime==null){
     wx.showModal({
       title: '提示',
       content: '不能为空！',
     })
    
   }
   else if (endTime<=startTime){
     wx.showModal({
       title: '提示',
       content: '结束时间必须大于开始时间！',
     })
   }

   
    else{
     wx.showToast({
          title: '创建成功',
          icon:'success',
          duration:2000
    }),
      //  console.log(UserID);
       wx.request({
       url: 'https://ke.slickghost.com/dk/createActivity.php',
        //  console.log(UserID),
         data: {
           activityName: name,
           activityContent: content,
           startTime: startTime,
           endTime: endTime,
           UserID: UserID
         }
        
    }),
       wx.switchTab({
        url: '../index/index',
       })
    
    }
  }
})